﻿using MediatR;
using Warehouse.API.Applcation.Command.StorehouseCommand;
using Warehouse.Infrstructre.Interface;
namespace Warehouse.API.Applcation.CommandHandlers.StorehouseCommandHandlers
{
    public class UpdateStorehouseCommandHandlers:IRequestHandler<UpdateStorehouseCommand,int>
    {
        private readonly IStorehouseRepository _storehouse;

        public UpdateStorehouseCommandHandlers(IStorehouseRepository storehouse)
        {
            this._storehouse = storehouse;
        }

        public async Task<int> Handle(UpdateStorehouseCommand request, CancellationToken cancellationToken)
        {


            return await _storehouse.UpdateAsync(new Domain.StoreHouse() { StorehouseId = request.StorehouseId, StorehouseName = request.StorehouseName, StorehouseCode = request.StorehouseCode, StorehouseType = request.StorehouseType, WarehouseId = request.WarehouseId, IsDefaults = request.IsDefaults, IsDisable = request.IsDisable, CreatTime = request.CreatTime, Sremark = request.Sremark, AddName = request.AddName, AddTime = request.AddTime,UpdName = request.UpdName,UpdTime =request.UpdTime, office_id = request.office_id, user_id = request.user_id });
        }
    }
}
